# Maintainer: kpcyrd <git@rxv.cc>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>

pkgname=cargo-audit
pkgver=0.18.3
pkgrel=1
pkgdesc="Audit Cargo.lock for crates with security vulnerabilities"
url="https://github.com/RustSec/cargo-audit"
depends=('cargo')
arch=('loong64' 'x86_64')
license=('MIT' 'APACHE')
options=(!lto)
source=("https://github.com/RustSec/rustsec/archive/${pkgname}/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('db58c773e4a6d308ec71ce7119435c9139d271bf60bcf0e42b6ba9bb1aa6879f')
b2sums=('a3fd2dd5d2382fb5dc4733af86a3a9535154e4f8f846f8c8f013f270bd4ac3932f8070ecf67ada43d4b746c29be444858cb09dcd1e01af70f757032d34d40c05')

prepare() {
  cd rustsec-${pkgname}-v${pkgver}/${pkgname}
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd rustsec-${pkgname}-v${pkgver}
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --release --locked --features fix
}

check() {
  cd rustsec-${pkgname}-v${pkgver}/${pkgname}
  export RUSTUP_TOOLCHAIN=stable
  cargo test --release --locked
}

package() {
  cd rustsec-${pkgname}-v${pkgver}/${pkgname}
  install -Dm755 "../target/release/${pkgname}" -t "${pkgdir}"/usr/bin
  install -Dm644 LICENSE-MIT -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
